﻿var W = screen.width; //取得屏幕分辨率宽度
var H = screen.height; //取得屏幕分辨率高度
//判断浏览器是否为IE
function isIE() {
    return (document.all && window.ActiveXObject && !window.opera) ? true : false;
}

//取得页面的高宽
function getBodySize() {
    var bodySize = [];
    with (document.documentElement) {
        bodySize[0] = (scrollWidth > clientWidth) ? scrollWidth : clientWidth; //如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
        bodySize[1] = (scrollHeight > clientHeight) ? scrollHeight : clientHeight; //如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
    }
    return bodySize;
}

//创建遮盖层
function popCoverDiv() {
    if ($("#divCover").css('display') == 'none') {
        $("#divCover").css('display', 'block');
    }
    else {
        //否则创建遮盖层
        var coverDiv = document.getElementById("divCover"); //MC('div');
        //document.body.appendChild(coverDiv);
        //coverDiv.id = 'cover_div';
        with (coverDiv.style) {
            position = 'absolute';
            background = '#CCCCCC';
            left = '0px';
            top = '0px';
            var bodySize = getBodySize();
            width = bodySize[0] + 'px'
            height = bodySize[1] + 'px';
            zIndex = 0;
            if (isIE()) {
                filter = "Alpha(Opacity=60)"; //IE逆境
            }
            else {
                opacity = 0.6;
            }
        }
    }
}


//让登陆层显示为块
function showLogin() {
    var login = $("#login");
    login.css('display', 'block');
}

//设置DIV层的样式
function change() {
    var login = $("#login");
    login.css('position', 'absolute');
    login.css('border', '1px solid #CCCCCC');
    login.css('background', '#F6F6F6');
    var i = 0;
    var bodySize = getBodySize();
    login.css('left', (bodySize[0] - i * i * 4) / 2 + "px");
    login.css('top', (bodySize[1] / 2 - 100 - i * i) + "px");
    login.css('width', i * i * 4 + "px");
    login.css('height', i * i * 1.5 + "px");
    popChange(i);
}

//让DIV层大小循环增大
function popChange(i) {
    var login = $("#login");
    var bodySize = getBodySize();
    login.css("left", (bodySize[0] - i * i * 4) / 2 + "px");
    login.css("top", (bodySize[1] / 2 - 100 - i * i) + "px");
    login.css("width", i * i * 4 + "px");
    login.css("height", i * i * 1.5 + "px");
    if (i <= 6) {
        i++;
        setTimeout("popChange(" + i + ")", 10); //设置超时10毫秒
    }
}

//打开DIV层
function open() {
    change();
    showLogin();
    popCoverDiv();
    //            void (0); //不进行任何操作,如：<a href="#">aaa</a>
}
//关闭DIV层
function close() {
    $('#login').css('display', 'none');
    $("#divCover").css('display', 'none');
    void (0);
}

//以下是上传图片用的脚本
$(document).ready(function() {
    $("#img").bind("click", open);
    $('#fileInnerImg').uploadify({
        'uploader': '../uploadidy/uploadify.swf',
        'script': '../uploadidy/UploadHandler.ashx',
        'cancelImg': '../uploadidy/cancel.png',
        'auto': true,
        'multi': true,
        'simUploadLimit': 1,
        'fileDesc': '图片文件', //出现在上传对话框中的文件类型描述 
        'fileExt': '*.jpg;*.bmp;*.png;*.gif',      //控制可上传文件的扩展名，启用本项时需同时声明fileDesc 
        //        'buttonImg' : 'Images/pic_fun_btn1.gif',
        'buttonImg': '../uploadidy/folder_up.gif',
        'folder': '../UploadFile',
        'width': 40,
        'height': 40,
        'sizeLimit': 5120000,
        'onComplete': function(e, queueId, fileObj, response, data) {
            $("#EmployeeImagePath").attr("src", "../UploadFile/" + response);
            //            var sa=response.split(","); 
            //            $(".room_map_images").append("<div class=\"room_map_images_ones\"><input type=\"hidden\" name=\"hidHuXingImg\" value=\""+response+"\" /><img alt=\"\" src=\"http://124.42.124.207:8008"+sa[2]+"\" width=\"100\" height=\"75\" /><a style=\"cursor:pointer;\">删除</a><div style=\"clear:both\"></div></div>");
        },
        'onAllComplete': function(event, data) {
            setTimeout("close()", 500);
        },
        'onError': function(a, b, c, d, e) {
            if (c.size > 5120000) {
                setTimeout("$('#fileInput').uploadifyClearQueue()", 5120);
                alert("请上传小于5120k的图片！");
            }
        }
    });
});  